<!--
 * @Author: ckk
 * @Date: 2022-08-11 18:16:34
 * @LastEditors: ckk
 * @LastEditTime: 2022-10-25 19:13:50
 * @Description: 金刚区 一行四个，最多两行
-->
<template>
  <div class="jingang-district">
    <div class="jingang-item" v-for="(item, index) in datas" :key="index">
      <img :src="item.src" alt="" :style="{ borderRadius:setStyle.borderRadius+'px' }" @click="goJinGang(item)">
      <p :style="{ color:setStyle.textColor, fontSize:setStyle.textSize+'px' }">{{item.text}}</p>
    </div>
  </div>
</template>

<script>
import { getLink } from '../../../common/comfun';
import { Toast } from 'yj-mob-ui';
import { Base64 } from 'js-base64';
export default {
  name: 'jingangDistrict',
  components: {
    [Toast.name]: Toast
  },
  props: {
    datas: Array,
    setStyle: Object
  },
  data () {
    return {
    };
  },
  methods: {
    goJinGang (item) {
      if (item.url !== undefined) {
        if (item.url.includes('.json?type=7100854158334001076') || item.url.includes('.json?type=7543721344441725193')) {
          const requestParam = {
            title: item.text,
            templateUrl: Base64.encode(item.url)
          };
          this.$router.push({ path: '../../../secondPage', query: requestParam });
        } else {
          // window.location.href = getLink(item.url);
          if (getLink(item.url)) {
            var goUrl = getLink(item.url);
            if (goUrl.indexOf('&cuparam') !== 0) {
              // goUrl = getLink(item.url).split('&cuparam')[0];
              goUrl = getLink(item.url).split('&cuparam')[0] + '?H5=1';
            }
            window.location.href = goUrl;
          }
        }
      } else {
        this.$toast('暂无跳转链接');
      }
    }
  }
};
</script>

<style scoped lang="scss">
.jingang-district{
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    padding-top:16px;
    border-radius: 10px;
}
.jingang-item{
    width:25%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom:16px;
    img {
      width:48px;
      height:48px;
      margin-bottom:4px;
    }
    p {
        font-size: 12px;
font-weight: 400;
color: rgba(0,0,0,0.6500);
margin-top:4px
    }
}
</style>
